﻿namespace DailyReport.Web.Controllers
{
    [Authorize(Roles = "None")]
    public partial class DailyController : Controller
    {
        private readonly DailyService _dailyService;

        public DailyController(DailyService dailyService)
        {
            _dailyService = dailyService;
        }

        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Timeline()
        {
            return View();
        }

        /// <summary>
        /// 查询所有/分页
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost("daily/pages")]
        public async Task<RestfulResult<PageResult<ReportDetailOutDto>>> GetPagesAsync([FromBody] PageParam data)
        {
            return await _dailyService.GetPagesAsync(data);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost("daily/submit")]
        public async Task<RestfulResult> SubmitAsync([FromBody] ReportDetail data)
        {
            return await _dailyService.SubmitAsync(data);
        }
    }
}
